home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1996 April: Mac OS SDK / Dev.CD Apr 96 SDK / Dev.CD Apr 96 SDK1.toast / Development Kits (Disc 1) / OpenDoc / Sample Code / Sample Editors⁄Viewers / SamplePart (C++) / Source / SamplePartUtils.h < prev    next >
Encoding:
C/C++ Source or Header  |  1995-12-07  |  6.0 KB  |  266 lines  |  [TEXT/MPS ]

  1. /*
  2.     File:        SamplePartUtils.h
  3.  
  4.     Contains:    SamplePart utility functions & classes
  5.  
  6.     Written by:    Steve Smith
  7.  
  8.     Copyright:    © 1994,95 by Apple Computer, Inc., all rights reserved.
  9. */
  10.  
  11.  
  12. #ifndef _SAMPLEPARTUTILS_
  13. #define _SAMPLEPARTUTILS_
  14.  
  15. // --- SamplePart Includes ---
  16.  
  17. #ifndef _SAMPLECOLLECTIONS_
  18. #include "SampleCollections.h"
  19. #endif
  20.  
  21. // --- OpenDoc Includes ---
  22.  
  23. #ifndef _ODTYPES_
  24. #include <ODTypes.h>
  25. #endif
  26.  
  27. #ifndef SOM_ODFrame_xh
  28. #include <Frame.xh>
  29. #endif
  30.  
  31. // --- OpenDoc Utilities ---
  32.  
  33. #ifndef _ITEXT_
  34. #include <IText.h>
  35. #endif
  36.  
  37. #ifndef _ODUTILS_
  38. #include <ODUtils.h>
  39. #endif
  40.  
  41. #ifndef _ODDEBUG_
  42. #include <ODDebug.h>
  43. #endif
  44.  
  45. #ifndef _TEMPOBJ_
  46. #include <TempObj.h>
  47. #endif
  48.  
  49. // --- Macintosh Includes ---
  50.  
  51. #ifndef __TYPES__
  52. #include <Types.h>
  53. #endif
  54.  
  55. // --- Forward Declarations ---
  56. class ODDraft;
  57. class ODFacet;
  58. class ODWindow;
  59. class ODStorageUnitView;
  60.  
  61. //------------------------------------------------------------------------------
  62. // Function Prototypes
  63. //------------------------------------------------------------------------------
  64.  
  65. ODIText*        GetPartName(Environment* ev, ODPart* part, ODType category);
  66. ODBoolean        NamesAreEquivalent(Environment* ev, ODIText* fileName,
  67.                                         ODIText* partName);
  68. void            GetEditorScriptLanguage(Environment* ev, ODScriptCode* script,
  69.                                         ODLangCode* language);
  70. void            FixedToIntRect(ODRect& fixedRect, Rect& intRect);
  71. void            IntToFixedRect(Rect& intRect, ODRect& fixedRect);
  72. void            LoadThumbnail(Environment* ev, Handle* thumbnail);
  73. Rect            TilePartWindow(Environment* ev, Rect* facetBounds,
  74.                                         Rect* partWindowBounds);
  75. ODUShort        CountFramesFacets(Environment* ev, ODFrame* frame);
  76.                                         
  77. //------------------------------------------------------------------------------
  78. // Utility Class Definitions
  79. //------------------------------------------------------------------------------
  80.  
  81. class CFrameProxy // (aka CFuton)
  82. {
  83.     public:
  84.     CFrameProxy();
  85.     ~CFrameProxy();
  86.     
  87.     void        InitFrameProxy(ODID frameID, ODDraft* draft);
  88.     void        InitFrameProxy(Environment* ev, ODFrame* frame);
  89.     void        Purge(Environment* ev);
  90.  
  91.     ODFrame*    GetFrame(Environment* ev);
  92.     void        SetFrame(Environment* ev, ODFrame* frame);
  93.     ODBoolean    FrameIsLoaded(Environment* ev);
  94.     ODID        GetID();
  95.     ODDraft*    GetDraft();
  96.     
  97.     private:
  98.     ODFrame*    fFrame;
  99.     ODID        fID;
  100.     ODDraft*    fDraft;
  101. };
  102.  
  103. class CFrameInfo
  104. {
  105.     public:
  106.             CFrameInfo(ODSession* session);
  107.             ~CFrameInfo();
  108.     
  109.     void    Externalize(Environment* ev, ODStorageUnitView* storageUnitView);
  110.     void    CleanseFrameInfoProperty(Environment* ev, ODStorageUnit* storageUnit);
  111.     void    ExternalizeFrameInfo(Environment* ev, ODStorageUnit* storageUnit,
  112.                                     ODDraftKey key, ODFrame* scopeFrame);
  113.     void    CloneInto(Environment *ev, ODDraftKey key,
  114.                                     ODStorageUnitView* storageUnitView,
  115.                                     ODFrame* scopeFrame);
  116.     void    InitFromStorage(Environment* ev, ODStorageUnitView* storageUnitView);
  117.                 
  118.     ODBoolean        IsFrameActive();
  119.     void            SetFrameActive(ODBoolean active);
  120.     ODBoolean        FrameNeedsReactivating();
  121.     void            SetFrameReactivate(ODBoolean reactivate);
  122.     ODFacet*        GetActiveFacet();
  123.     void            SetActiveFacet(ODFacet* facet);
  124.     void            SetSourceFrame(Environment* ev, ODFrame* frame);
  125.     ODFrame*        GetSourceFrame(Environment* ev);
  126.     void            ReleaseSourceFrame(Environment* ev);
  127.     ODBoolean        HasSourceFrame();
  128.     ODWindow*        AcquirePartWindow(Environment* ev);
  129.     void            SetPartWindow(Environment* ev, ODWindow* window);
  130.     void            SetDependentFrame(Environment* ev, ODFrame* frame);
  131.     ODFrame*        GetDependentFrame(Environment* ev);
  132.     ODBoolean        HasDependentFrame();
  133.     void            ReleaseDependentFrame(Environment* ev);
  134.     void            SetShouldDisposeWindow(ODBoolean should);
  135.     ODBoolean        ShouldDisposeWindow();
  136.     
  137.     private:
  138.     CFrameInfo(); /* don't want parts to call */
  139.     
  140.     ODSession*        fSession;
  141.     ODBoolean        fFrameActive;
  142.     ODBoolean        fFrameReactivate;
  143.     ODBoolean        fShouldDisposeWindow;
  144.     ODFacet*        fActiveFacet;
  145.     CFrameProxy*    fSourceFrame;
  146.     CFrameProxy*    fDependentFrame;
  147.     ODID            fPartWindowID;
  148. };
  149.  
  150.  
  151.  
  152.  
  153. //-------------------------------------------------------------------------
  154. // Inline methods
  155. //-------------------------------------------------------------------------
  156.  
  157. //=========================================================================
  158. // CFrameProxy
  159. //=========================================================================
  160.  
  161. inline CFrameProxy::CFrameProxy()
  162. {
  163.     fFrame = kODNULL;
  164.     fID = kODNULLID;
  165.     fDraft = kODNULL;
  166. }
  167.     
  168. inline CFrameProxy::~CFrameProxy()
  169. {
  170.     ODSafeReleaseObject(fFrame);
  171. }
  172.     
  173. inline void CFrameProxy::InitFrameProxy(ODID frameID, ODDraft* draft)
  174. {
  175.     ASSERT(draft!=kODNULL, kODErrIllegalNullInput);
  176.     
  177.     fFrame = kODNULL;
  178.     fID = frameID;
  179.     fDraft = draft;
  180. }
  181.     
  182. inline void CFrameProxy::InitFrameProxy(Environment* ev, ODFrame* frame)
  183. {
  184.     ASSERT(frame!=kODNULL, kODErrIllegalNullFrameInput);
  185.     
  186.     this->SetFrame(ev,frame);
  187. }
  188.  
  189. inline ODID CFrameProxy::GetID()
  190. {
  191.     return fID;
  192. }
  193.  
  194. inline ODDraft* CFrameProxy::GetDraft()
  195. {
  196.     return fDraft;
  197. }
  198.  
  199.  
  200. //=========================================================================
  201. // CFrameInfo
  202. //=========================================================================
  203.  
  204. inline ODBoolean CFrameInfo::IsFrameActive()
  205. {
  206.     return fFrameActive;
  207. }
  208.  
  209. inline void CFrameInfo::SetFrameActive(ODBoolean active)
  210. {
  211.     fFrameActive = active;
  212. }
  213.  
  214. inline ODBoolean CFrameInfo::FrameNeedsReactivating()
  215. {
  216.     return fFrameReactivate;
  217. }
  218.  
  219. inline void CFrameInfo::SetFrameReactivate(ODBoolean reactivate)
  220. {
  221.     fFrameReactivate = reactivate;
  222. }
  223.  
  224. inline ODFacet* CFrameInfo::GetActiveFacet()
  225. {
  226.     return fActiveFacet;
  227. }
  228.  
  229. inline void CFrameInfo::SetActiveFacet(ODFacet* facet)
  230. {
  231.     fActiveFacet = facet;
  232. }
  233.  
  234. inline ODFrame* CFrameInfo::GetSourceFrame(Environment* ev)
  235. {
  236.     return (fSourceFrame->GetFrame(ev));
  237. }
  238.  
  239. inline ODBoolean CFrameInfo::HasSourceFrame()
  240. {
  241.     return (fSourceFrame != kODNULL);
  242. }
  243.  
  244. inline ODFrame* CFrameInfo::GetDependentFrame(Environment* ev)
  245. {
  246.     return (fDependentFrame->GetFrame(ev));
  247. }
  248.  
  249. inline ODBoolean CFrameInfo::HasDependentFrame()
  250. {
  251.     return (fDependentFrame != kODNULL);
  252. }
  253.  
  254. inline void CFrameInfo::SetShouldDisposeWindow(ODBoolean should)
  255. {
  256.     fShouldDisposeWindow = should;
  257. }
  258.  
  259. inline ODBoolean CFrameInfo::ShouldDisposeWindow()
  260. {
  261.     return fShouldDisposeWindow;
  262. }
  263.  
  264. #endif
  265.  
  266.